home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Reading Formatted Text.2 < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  1.4 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Reading Formatted Text
  2. Sent:        6/11/96 2:42 PM
  3. Received:    6/11/96 2:51 PM
  4. From:        Serge Froment, sfroment@odyssee.net
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >However, I am a bit concerned about the efficiency of such a method in the
  9. >case the clipboard contain a large text. (I was done writing the code late
  10. >last evening and I have not yet tested what happen in that case.)
  11.  
  12. Actually, It was way too late last evening when I wrote the code of my
  13. previous message. Using both FW_CTextReader and FW_CStringWriter does a
  14. much nicer job:
  15.  
  16. void CMyData::ReadString(FW_CTextReader& textReader, FW_CString& string,
  17. FW_LChar delimiter)
  18. {
  19.         string.Truncate(0);
  20.         FW_Boolean seeking = true;
  21.         FW_CStringWriter textWriter(string);
  22.         while (seeking && textReader.GetPosition() < textReader.GetByteLength())
  23.         {
  24.                 FW_LChar ch = textReader.PeekCharacter();
  25.                 if (ch == delimiter)
  26.                 {
  27.                         textReader.Advance();
  28.                         seeking = false;
  29.                 }
  30.                 else if (ch == '\r')
  31.                 {
  32.                         seeking = false;
  33.                 }
  34.                 else
  35.                 {
  36.                         textWriter.PutCharacterAndAdvance(ch);
  37.                         textReader.Advance();
  38.                 }
  39.         }
  40. }
  41.  
  42. Serge
  43.  
  44.